﻿$(window).resize(function () {
    $("#content").css("height", $(".layui-body").height() - 75);
});

$(function () {
    //权限全选
    $("input[name='checkAll']").click(function () {
        if ($(this).prop("checked") == true) {

            $(this).parent().parent().siblings("td").find("div").find("input[type='checkbox']").prop("checked", true);
        } else {
            $(this).parent().parent().siblings("td").find("div").find("input[type='checkbox']").prop("checked", false);
        }
    });
    $("#content").css("height", $(".layui-body").height() - 75);

});
//返回
$("#btn_Return").click(function () {
    window.location.href = '/Role/RoleIndex';
});
layui.config({
    base: "../Content/layui/lay/modules/"
}).use(['element', 'jquery', 'multiSelect', 'form', 'layedit', 'laydate'], function () {
    var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
    //监听导航点击
    element.on('nav(demo)', function (elem) {
        //console.log(elem)
        layer.msg(elem.text());
    });
    var active = {
        close: function (data) {
            //layer.close(layer.index);
        }
    };



    var form = layui.form, layer = layui.layer


    function getrightobj(list, right, type) {
        var hasright = false;
        list.forEach(v => {
            if (v.MenuId === right.MenuId) {
                getright(v, type);
                hasright = true;
                return;
            }
        });
        if (!hasright) {
            getright(right, type);
            list.push(right);
        }
    }

    function getright(right, type) {
        if (type == "add") {
            right.IsCanAdd = 1;
        }
        if (type == "view") {
            right.IsCanView = 1;
        }
        if (type == "list" || type == "export") {
            right.IsCanView = 1;
        }
        if (type == "update") {
            right.IsCanUpdate = 1;
        }
        if (type == "delete") {
            right.IsCanDelete = 1;
        }
    }

    form.on("checkbox()", function (data) {
        if (!data.elem.id) {
            var id = $("#" + data.elem.name).data("id");
            checkallchange(id);
            form.render();
        }
    })
});
